$(document).ready(function () {
    var list = $('#List');
    $('.xh-datagrid-toolbar').parseToolbar();
    $('.xh-form').parseForm($('#bt_form_add, #bt_form_edit'));
    var id = getQueryString('id');
    /**初始化列表**/
    list.initDataGrid(moduleUrl + 'Service/getUserDevices?id=' + id).setSelectThenEnable(['bt_list_del']);
    //用户id
    var userName = $.trim($('#user_name').text());
    var userId = parseInt($('#user_id').text().replace(/[^0-9]/ig, ""));
    console.log(userName);
    console.log(userId);
    //发起协助 添加协助
    DataGrid.onDblClickRow = function (rowIndex, rowData) {
        if (confirm('发起协助?')) {
            var deviceId = rowData.deviceId;
            console.log(rowData.deviceId);
            $.get(
                moduleUrl + 'Service/createAssist?deviceId=' + deviceId + "&userName=" + userName + "&userId=" + userId,
                function (data, status, xhr) {
                    //创建成功
                    if (xhr.status === 200) {
                        var assistId = data;
                        var url = moduleUrl + "assist/detail?id=" + assistId;
                        // location.href = url;
                        window.top.xhTop.createNewTab('协助详情',url);
                    }
                    else {
                        $.messager.show({
                            msg: '创建失败！'
                        });
                    }
                },
                'json'
            )
        }
    };
});
/**  获取url参数**/
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var url = decodeURI(decodeURI(window.location.search))
    var r = url.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}